using System;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.InteropServices;

using ILRuntime.CLR.TypeSystem;
using ILRuntime.CLR.Method;
using ILRuntime.Runtime.Enviorment;
using ILRuntime.Runtime.Intepreter;
using ILRuntime.Runtime.Stack;
using ILRuntime.Reflection;
using ILRuntime.CLR.Utils;
using System.Linq;

namespace ILRuntime.Runtime.Generated
{
    unsafe class huqiang_Communication_Msg_Binding
    {
        public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app)
        {
            BindingFlags flag = BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly;
            MethodBase method;
            FieldInfo field;
            Type[] args;
            Type type = typeof(huqiang.Communication.Msg);

            field = type.GetField("DataType", flag);
            app.RegisterCLRFieldGetter(field, get_DataType_0);
            app.RegisterCLRFieldSetter(field, set_DataType_0);
            app.RegisterCLRFieldBinding(field, CopyToStack_DataType_0, AssignFromStack_DataType_0);
            field = type.GetField("CmdType", flag);
            app.RegisterCLRFieldGetter(field, get_CmdType_1);
            app.RegisterCLRFieldSetter(field, set_CmdType_1);
            app.RegisterCLRFieldBinding(field, CopyToStack_CmdType_1, AssignFromStack_CmdType_1);
            field = type.GetField("Cmd", flag);
            app.RegisterCLRFieldGetter(field, get_Cmd_2);
            app.RegisterCLRFieldSetter(field, set_Cmd_2);
            app.RegisterCLRFieldBinding(field, CopyToStack_Cmd_2, AssignFromStack_Cmd_2);
            field = type.GetField("Error", flag);
            app.RegisterCLRFieldGetter(field, get_Error_3);
            app.RegisterCLRFieldSetter(field, set_Error_3);
            app.RegisterCLRFieldBinding(field, CopyToStack_Error_3, AssignFromStack_Error_3);
            field = type.GetField("Args", flag);
            app.RegisterCLRFieldGetter(field, get_Args_4);
            app.RegisterCLRFieldSetter(field, set_Args_4);
            app.RegisterCLRFieldBinding(field, CopyToStack_Args_4, AssignFromStack_Args_4);
            field = type.GetField("Data", flag);
            app.RegisterCLRFieldGetter(field, get_Data_5);
            app.RegisterCLRFieldSetter(field, set_Data_5);
            app.RegisterCLRFieldBinding(field, CopyToStack_Data_5, AssignFromStack_Data_5);
            field = type.GetField("user", flag);
            app.RegisterCLRFieldGetter(field, get_user_6);
            app.RegisterCLRFieldSetter(field, set_user_6);
            app.RegisterCLRFieldBinding(field, CopyToStack_user_6, AssignFromStack_user_6);


            app.RegisterCLRCreateDefaultInstance(type, () => new huqiang.Communication.Msg());
            app.RegisterCLRCreateArrayInstance(type, s => new huqiang.Communication.Msg[s]);

            args = new Type[]{};
            method = type.GetConstructor(flag, null, args, null);
            app.RegisterCLRMethodRedirection(method, Ctor_0);

        }



        static object get_DataType_0(ref object o)
        {
            return ((huqiang.Communication.Msg)o).DataType;
        }

        static StackObject* CopyToStack_DataType_0(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = ((huqiang.Communication.Msg)o).DataType;
            __ret->ObjectType = ObjectTypes.Integer;
            __ret->Value = result_of_this_method;
            return __ret + 1;
        }

        static void set_DataType_0(ref object o, object v)
        {
            ((huqiang.Communication.Msg)o).DataType = (System.Byte)v;
        }

        static StackObject* AssignFromStack_DataType_0(ref object o, ILIntepreter __intp, StackObject* ptr_of_this_method, IList<object> __mStack)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            System.Byte @DataType = (byte)ptr_of_this_method->Value;
            ((huqiang.Communication.Msg)o).DataType = @DataType;
            return ptr_of_this_method;
        }

        static object get_CmdType_1(ref object o)
        {
            return ((huqiang.Communication.Msg)o).CmdType;
        }

        static StackObject* CopyToStack_CmdType_1(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = ((huqiang.Communication.Msg)o).CmdType;
            __ret->ObjectType = ObjectTypes.Integer;
            __ret->Value = result_of_this_method;
            return __ret + 1;
        }

        static void set_CmdType_1(ref object o, object v)
        {
            ((huqiang.Communication.Msg)o).CmdType = (System.Byte)v;
        }

        static StackObject* AssignFromStack_CmdType_1(ref object o, ILIntepreter __intp, StackObject* ptr_of_this_method, IList<object> __mStack)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            System.Byte @CmdType = (byte)ptr_of_this_method->Value;
            ((huqiang.Communication.Msg)o).CmdType = @CmdType;
            return ptr_of_this_method;
        }

        static object get_Cmd_2(ref object o)
        {
            return ((huqiang.Communication.Msg)o).Cmd;
        }

        static StackObject* CopyToStack_Cmd_2(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = ((huqiang.Communication.Msg)o).Cmd;
            __ret->ObjectType = ObjectTypes.Integer;
            __ret->Value = result_of_this_method;
            return __ret + 1;
        }

        static void set_Cmd_2(ref object o, object v)
        {
            ((huqiang.Communication.Msg)o).Cmd = (System.UInt16)v;
        }

        static StackObject* AssignFromStack_Cmd_2(ref object o, ILIntepreter __intp, StackObject* ptr_of_this_method, IList<object> __mStack)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            System.UInt16 @Cmd = (ushort)ptr_of_this_method->Value;
            ((huqiang.Communication.Msg)o).Cmd = @Cmd;
            return ptr_of_this_method;
        }

        static object get_Error_3(ref object o)
        {
            return ((huqiang.Communication.Msg)o).Error;
        }

        static StackObject* CopyToStack_Error_3(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = ((huqiang.Communication.Msg)o).Error;
            __ret->ObjectType = ObjectTypes.Integer;
            __ret->Value = result_of_this_method;
            return __ret + 1;
        }

        static void set_Error_3(ref object o, object v)
        {
            ((huqiang.Communication.Msg)o).Error = (System.UInt16)v;
        }

        static StackObject* AssignFromStack_Error_3(ref object o, ILIntepreter __intp, StackObject* ptr_of_this_method, IList<object> __mStack)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            System.UInt16 @Error = (ushort)ptr_of_this_method->Value;
            ((huqiang.Communication.Msg)o).Error = @Error;
            return ptr_of_this_method;
        }

        static object get_Args_4(ref object o)
        {
            return ((huqiang.Communication.Msg)o).Args;
        }

        static StackObject* CopyToStack_Args_4(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = ((huqiang.Communication.Msg)o).Args;
            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }

        static void set_Args_4(ref object o, object v)
        {
            ((huqiang.Communication.Msg)o).Args = (System.String)v;
        }

        static StackObject* AssignFromStack_Args_4(ref object o, ILIntepreter __intp, StackObject* ptr_of_this_method, IList<object> __mStack)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            System.String @Args = (System.String)typeof(System.String).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            ((huqiang.Communication.Msg)o).Args = @Args;
            return ptr_of_this_method;
        }

        static object get_Data_5(ref object o)
        {
            return ((huqiang.Communication.Msg)o).Data;
        }

        static StackObject* CopyToStack_Data_5(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = ((huqiang.Communication.Msg)o).Data;
            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }

        static void set_Data_5(ref object o, object v)
        {
            ((huqiang.Communication.Msg)o).Data = (System.Byte[])v;
        }

        static StackObject* AssignFromStack_Data_5(ref object o, ILIntepreter __intp, StackObject* ptr_of_this_method, IList<object> __mStack)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            System.Byte[] @Data = (System.Byte[])typeof(System.Byte[]).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            ((huqiang.Communication.Msg)o).Data = @Data;
            return ptr_of_this_method;
        }

        static object get_user_6(ref object o)
        {
            return ((huqiang.Communication.Msg)o).user;
        }

        static StackObject* CopyToStack_user_6(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = ((huqiang.Communication.Msg)o).user;
            object obj_result_of_this_method = result_of_this_method;
            if(obj_result_of_this_method is CrossBindingAdaptorType)
            {    
                return ILIntepreter.PushObject(__ret, __mStack, ((CrossBindingAdaptorType)obj_result_of_this_method).ILInstance);
            }
            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }

        static void set_user_6(ref object o, object v)
        {
            ((huqiang.Communication.Msg)o).user = (huqiang.Communication.KcpUser)v;
        }

        static StackObject* AssignFromStack_user_6(ref object o, ILIntepreter __intp, StackObject* ptr_of_this_method, IList<object> __mStack)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            huqiang.Communication.KcpUser @user = (huqiang.Communication.KcpUser)typeof(huqiang.Communication.KcpUser).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            ((huqiang.Communication.Msg)o).user = @user;
            return ptr_of_this_method;
        }



        static StackObject* Ctor_0(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject* __ret = ILIntepreter.Minus(__esp, 0);

            var result_of_this_method = new huqiang.Communication.Msg();

            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }


    }
}
